<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/template/main.xhtml">

	<ui:define name="body">

		<h:form id="test">



			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton value="#{messages['button.new']}"
						title="#{messages['button.new']}" icon="ui-icon-document"
						action="#{empresaListMB.getNextView}"
						actionListener="#{empresaListMB.clear}" ajax="false" />

					<p:commandButton value="#{messages['button.delete']}"
						title="#{messages['button.delete']}" icon="ui-icon-trash"
						onclick="confirmation.show()" type="button" immediate="true"
						ajax="false" />

					<p:confirmDialog message="#{messages['label.confirm.delete']}"
						showEffect="bounce" hideEffect="explode"
						header="#{messages['label.dialog.alert']}!" severity="alert"
						widgetVar="confirmation">

						<h:commandButton value="#{messages['button.dialog.yes']}"
							action="#{empresaListMB.deleteSelection}"
							actionListener="#{empresaListMB.clear}" />
						<h:commandButton value="#{messages['button.dialog.no']}"
							onclick="confirmation.hide()" type="button" />
					</p:confirmDialog>
				</p:toolbarGroup>
			</p:toolbar>

			<p:dataTable id="list" var="bean" value="#{empresaListMB.resultList}"
				rowKey="#{bean}" selectionMode="single" paginator="true" rows="20">

				<!--<p:ajax event="rowSelect" listener="#{empresaListMB.onRowSelect}"
					update=":form:display :form:growl" oncomplete="carDialog.show()" />
				<p:ajax event="rowUnselect"
					listener="#{empresaListMB.onRowUnselect}" update=":form:growl" />
				selection="#{empresaListMB.resultList}" -->

				<f:facet name="header">#{messages['empresa.list.table.title']}</f:facet>




				<p:column style="width:3%;">
					<h:selectBooleanCheckbox
						value="#{empresaListMB.selection[bean.id]}" />
				</p:column>


				<p:column sortBy="#{bean.codigoEmpresa}"
					filterBy="#{bean.codigoEmpresa}" filterStyle="width:100%;"
					style="width:8%;">
					<f:facet name="header">#{messages['empresa.label.codigo']}</f:facet>
					<h:commandLink action="#{empresaListMB.getNextView}"
						actionListener="#{empresaListMB.clear}">
						<h:outputText value="#{bean.codigoEmpresa}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>


				<p:column sortBy="#{bean.cnpj}" filterBy="#{bean.cnpj}"
					filterStyle="width:100%;" style="width:10%;">
					<f:facet name="header">#{messages['empresa.label.cnpj']}</f:facet>
					<h:commandLink action="#{empresaListMB.getNextView}"
						actionListener="#{empresaListMB.clear}">
						<h:outputText value="#{bean.cnpj}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>

				<p:column style="width:35%;" sortBy="#{bean.nomeFantasia}"
					filterBy="#{bean.nomeFantasia}" filterStyle="width:100%;">
					<f:facet name="header">#{messages['empresa.label.nome']}</f:facet>
					<h:outputText value="#{bean.nomeFantasia}" />
				</p:column>

				<p:column sortBy="#{bean.razaoSocial}"
					filterBy="#{bean.razaoSocial}" filterStyle="width:100%;">
					<f:facet name="header">#{messages['empresa.label.razao']}</f:facet>
					<h:commandLink action="#{empresaListMB.getNextView}" 
						actionListener="#{empresaListMB.clear}">
						<h:outputText value="#{bean.razaoSocial}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>

				<p:column style="width:4%">
					<p:commandButton id="selectButton" update=":form:display"
						oncomplete="carDialog.show()" icon="ui-icon-search" title="View">
						<f:param name="id" value="#{bean.id}" />
					</p:commandButton>
					
						<p:commandButton id="selectButton1" action="#{empresaListMB.getNextView}"
						 actionListener="#{empresaListMB.clear}" icon="ui-icon-search" title="Editar">	
						 <f:param name="id" value="#{bean.id}" />					
						</p:commandButton>
				</p:column>



			</p:dataTable>

		</h:form>

		<h:form id="form">
			<p:growl id="growl" showDetail="true" />
			<p:dialog id="dialog" header="Empresa Detalhe" widgetVar="carDialog"
				resizable="false" showEffect="explode" hideEffect="explode">

				<h:panelGrid id="display" columns="2" cellpadding="4">

					<h:outputText value="#{messages['empresa.label.codigo']}:" />
					<p:inplace id="ajaxInplace" editor="true">
						<p:inputText
							value="#{bean.id}"
							required="true" label="text" />
					</p:inplace>


					<h:outputText value="#{messages['empresa.label.cnpj']}:" />
					<h:outputText value="#{empresaListMB.dataModel.rowData.cnpj}" />

					<h:outputText value="#{messages['empresa.label.razao']}:" />
					<h:outputText
						value="#{empresaListMB.dataModel.rowData.razaoSocial}" />

					<h:outputText value="#{messages['empresa.label.nome']}:" />
					<h:outputText
						value="#{empresaListMB.dataModel.rowData.nomeFantasia}" />
				</h:panelGrid>
			</p:dialog>

		</h:form>
		<!---->
	</ui:define>
</ui:composition>